#include "StdAfx.h"
#include "CircuitSimStimulus.h"

CCircuitSimStimulus::CCircuitSimStimulus(void)
{
	m_dblPosX=0;
	m_dblPosY=0;
	m_dblColor[0]=0;
	m_dblColor[1]=0;
	m_dblColor[2]=0;
	m_bSelected=false;
	m_szCode=_T("");
}

CCircuitSimStimulus::CCircuitSimStimulus(const CCircuitSimStimulus *pEntityObj)
	: CCircuitUnit(pEntityObj)
{
	m_dblPosX=pEntityObj->GetPosX();
	m_dblPosY=pEntityObj->GetPosY();
	m_dblColor[0]=pEntityObj->GetColorR();
	m_dblColor[1]=pEntityObj->GetColorG();
	m_dblColor[2]=pEntityObj->GetColorB();
	m_bSelected=pEntityObj->GetSelect();
	m_szCode=pEntityObj->GetCode();
}

CCircuitSimStimulus::CCircuitSimStimulus(CICircuit *pParentEnt)
	: CCircuitUnit(pParentEnt)
{
	m_dblPosX=0;
	m_dblPosY=0;
	m_dblColor[0]=0;
	m_dblColor[1]=0;
	m_dblColor[2]=0;
	m_bSelected=false;
	m_szCode=_T("");
}

CCircuitSimStimulus::~CCircuitSimStimulus(void)
{
	Clear();
}

void CCircuitSimStimulus::Serialize(CArchive & ar)
{
	if (ar.IsStoring())
	{
		ar << m_dblPosX;
		ar << m_dblPosY;
		ar << m_dblColor[0];
		ar << m_dblColor[1];
		ar << m_dblColor[2];
		ar << m_bSelected;
		CObj::WriteString(ar, m_szCode);
	}
	else
	{
		ar >> m_dblPosX;
		ar >> m_dblPosY;
		ar >> m_dblColor[0];
		ar >> m_dblColor[1];
		ar >> m_dblColor[2];
		ar >> m_bSelected;
		CObj::ReadString(ar, m_szCode);
	}

	CCircuitUnit::Serialize(ar);
}

CObj *CCircuitSimStimulus::Clone() const
{
	return new CCircuitSimStimulus(this);
}

void CCircuitSimStimulus::Transform(const CMatrix transf)
{

}

bool CCircuitSimStimulus::GetBox(double & dblLeft, double & dblBottom, double & dblRight, double & dblTop) const
{
	return false;
}

void CCircuitSimStimulus::Clear()
{

}

void CCircuitSimStimulus::CopyDisplayObj(long lSourceLayerId, long lDestLayerId)
{
	CEntityObj::CopyDisplayObj(lSourceLayerId, lDestLayerId);
}

void CCircuitSimStimulus::DeleteDisplayObj(long lLayerId)
{
	CEntityObj::DeleteDisplayObj(lLayerId);
}

CDisplayObj *CCircuitSimStimulus::CreateDisplayObj(long lLayerId)
{
	CCircuitSimStimulusDisObj *pStimulusDis = new CCircuitSimStimulusDisObj(this);
	pStimulusDis->SetLayerId(lLayerId);
	return pStimulusDis;
}

void CCircuitSimStimulus::CalcBox()
{
	m_minX = m_dblPosX-10;
	m_minY = m_dblPosY;
	m_maxX = m_dblPosX;
	m_maxY = m_dblPosY+10;
}

eCircuitUnitEntType CCircuitSimStimulus::GetUnitType() const
{
	return CIRCUIT_STIMULUS;
}

double CCircuitSimStimulus::GetPosX() const
{
	return m_dblPosX;
}

double CCircuitSimStimulus::GetPosY() const
{
	return m_dblPosY;
}

double CCircuitSimStimulus::GetColorR() const
{
	return m_dblColor[0];
}

double CCircuitSimStimulus::GetColorG() const
{
	return m_dblColor[1];
}

double CCircuitSimStimulus::GetColorB() const
{
	return m_dblColor[2];
}

bool CCircuitSimStimulus::GetSelect() const
{
	return  m_bSelected;
}


CString CCircuitSimStimulus::GetCode() const
{
	return m_szCode;
}

void CCircuitSimStimulus::SetPosX( double dblPosX)
{
	m_dblPosX = dblPosX;
}

void CCircuitSimStimulus::SetPosY( double dblPosY)
{
	m_dblPosY = dblPosY;
}

void CCircuitSimStimulus::SetColorR( double colR)
{
	m_dblColor[0] = colR;
}

void CCircuitSimStimulus::SetColorG( double colG)
{
	m_dblColor[1] = colG;
}

void CCircuitSimStimulus::SetColorB( double colB)
{
	m_dblColor[2] = colB;
}

void CCircuitSimStimulus::SetSelect( bool bSelected)
{
	m_bSelected = bSelected;
}



void CCircuitSimStimulus::SetCode( CString szCode)
{
	m_szCode = szCode;
}
